package Parser;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;

/**
 * Simple node filter to keep only those we are looking for
 * There are 4 types of filter
 */
public class MyNodeFilter implements NodeFilter {
	private static final long serialVersionUID = 1900347864423688228L;
	int type;
	
	public MyNodeFilter()
	{
		super();
		type=0;
	}
	
	public MyNodeFilter(int t)
	{
		super();
		type=t;
	}
	@Override
	public boolean accept(Node arg0) {
		if(type==0)
		{
			if(arg0!=null && arg0.getParent()!=null && arg0.getParent().getText().contains("td") && arg0.getParent().getText().contains("width=33.3%") && arg0.getText().contains("href"))
			{
				return true;
			}
			return false;
		}
		else if(type==1)
		{
			if(arg0!=null && arg0.getParent()!=null && arg0.getParent().getText().contains("title") && arg0.getText().contains("Database:"))
			{
				return true;
			}
			return false;
		}
		else if(type==2)
		{
			if(arg0!=null && arg0.getParent()!=null && arg0.getParent().getText().contains("td") && arg0.getParent().getText().contains("class=table_header2") && arg0.getText().contains("name"))
			{
				return true;
			}
			return false;
		}
		else if(type==3)
		{
			if(arg0!=null && arg0.getParent()!=null && arg0.getParent().getText().contains("td"))
			{
				return true;
			}
			return false;
		}
		else
		{
			if(arg0!=null && arg0.getText().contains("Length"))
			{
				return true;
			}
			return false;
			
		}
	}
}
